package com.example.dao;

import com.example.domain.Book;
import com.example.domain.Record;
import com.github.pagehelper.Page;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

public interface RecordMapper {

    Integer addRecord(Record record);


    @Select("        <script>\n" +
            "            select * from record\n" +
            "            <where>\n" +
            "\n" +
            "                <if test=\"bookname != null and bookname.trim()!=''  \">\n" +
            "                    and record_bookname like concat('%',#{bookname},'%')\n" +
            "                </if>\n" +
            "                <if test=\"borrower != null and borrower.trim()!=''  \">\n" +
            "                    and record_borrower like concat('%',#{borrower},'%')\n" +
            "                </if>\n" +
            "\n" +
            "            </where>\n" +
            "        </script>")
    @Results( id ="recordMap" , value = {
            @Result(id = true,property = "id",column = "record_id"),
            @Result(property = "bookname",column = "record_bookname"),
            @Result(property = "borrower",column = "record_borrower"),
            @Result(property = "bookisbn",column = "record_bookisbn"),
            @Result(property = "borrowTime",column = "record_borrowTime"),
            @Result(property = "remandTime",column = "record_remandTime"),
    })
    Page<Record> searchRecords(Record record);

}
